package com.ysqcould.curriculum.service.impl;

import com.ysqcould.common.utils.DateUtils;
import com.ysqcould.curriculum.domain.CourseTag;
import com.ysqcould.curriculum.mapper.CourseTagMapper;
import com.ysqcould.curriculum.service.ICourseTagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课程标签Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-09-27
 */
@Service
public class CourseTagServiceImpl implements ICourseTagService 
{
    @Autowired
    private CourseTagMapper courseTagMapper;

    /**
     * 查询课程标签
     * 
     * @param id 课程标签主键
     * @return 课程标签
     */
    @Override
    public CourseTag selectCourseTagById(Long id)
    {
        return courseTagMapper.selectCourseTagById(id);
    }

    /**
     * 查询课程标签列表
     * 
     * @param courseTag 课程标签
     * @return 课程标签
     */
    @Override
    public List<CourseTag> selectCourseTagList(CourseTag courseTag)
    {
        return courseTagMapper.selectCourseTagList(courseTag);
    }

    /**
     * 新增课程标签
     * 
     * @param courseTag 课程标签
     * @return 结果
     */
    @Override
    public int insertCourseTag(CourseTag courseTag)
    {
        courseTag.setCreateTime(DateUtils.getNowDate());
        return courseTagMapper.insertCourseTag(courseTag);
    }

    /**
     * 修改课程标签
     * 
     * @param courseTag 课程标签
     * @return 结果
     */
    @Override
    public int updateCourseTag(CourseTag courseTag)
    {
        courseTag.setUpdateTime(DateUtils.getNowDate());
        return courseTagMapper.updateCourseTag(courseTag);
    }

    /**
     * 批量删除课程标签
     * 
     * @param ids 需要删除的课程标签主键
     * @return 结果
     */
    @Override
    public int deleteCourseTagByIds(Long[] ids)
    {
        return courseTagMapper.deleteCourseTagByIds(ids);
    }

    /**
     * 删除课程标签信息
     * 
     * @param id 课程标签主键
     * @return 结果
     */
    @Override
    public int deleteCourseTagById(Long id)
    {
        return courseTagMapper.deleteCourseTagById(id);
    }

    /**
     * 修改tag状态
     * @param tag
     * @return
     */
    @Override
    public int changeTagStatus(CourseTag tag) {
        CourseTag courseTag = courseTagMapper.selectCourseTagById(tag.getId());
        courseTag.setUpdateTime(DateUtils.getNowDate());
        courseTag.setStatus(tag.getStatus());
        return courseTagMapper.updateCourseTag(tag);
    }

    /**
     * 课程标签
     * @param userId 协会id
     * @return
     */
    @Override
    public List<CourseTag> selectList(Long userId) {
        CourseTag tag=new CourseTag();
        tag.setAsId(userId);
        List<CourseTag> courseTags = courseTagMapper.selectCourseTagList(tag);
        return courseTags;
    }

}
